using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace Adex
{
    /// <summary>
    /// Controller class for TEMPLATE
    /// </summary>
    [System.ComponentModel.DataObject]
    public partial class TemplateController
    {
        // Preload our schema..
        Template thisSchemaLoad = new Template();
        private string userName = String.Empty;
        protected string UserName
        {
            get
            {
				if (userName.Length == 0) 
				{
    				if (System.Web.HttpContext.Current != null)
    				{
						userName=System.Web.HttpContext.Current.User.Identity.Name;
					}
					else
					{
						userName=System.Threading.Thread.CurrentPrincipal.Identity.Name;
					}
				}
				return userName;
            }
        }
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public TemplateCollection FetchAll()
        {
            TemplateCollection coll = new TemplateCollection();
            Query qry = new Query(Template.Schema);
            coll.LoadAndCloseReader(qry.ExecuteReader());
            return coll;
        }
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public TemplateCollection FetchByID(object Id)
        {
            TemplateCollection coll = new TemplateCollection().Where("ID", Id).Load();
            return coll;
        }
		
		[DataObjectMethod(DataObjectMethodType.Select, false)]
        public TemplateCollection FetchByQuery(Query qry)
        {
            TemplateCollection coll = new TemplateCollection();
            coll.LoadAndCloseReader(qry.ExecuteReader()); 
            return coll;
        }
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public bool Delete(object Id)
        {
            return (Template.Delete(Id) == 1);
        }
        [DataObjectMethod(DataObjectMethodType.Delete, false)]
        public bool Destroy(object Id)
        {
            return (Template.Destroy(Id) == 1);
        }
        
        
    	
	    /// <summary>
	    /// Inserts a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Insert, true)]
	    public void Insert(int UserID,string Slide1,string Slide2,string Slide3,string Slide4,string Slide5,string Slide6,string Slide7,string Slide8,string TvSmall,string TvBig,string CableSmall,string CableBig,string RadioSmall,string RadioBig,string RadioIntSmall,string RadioIntBig,string OutdoorSmall,string OutdoorBig,string OutdoorIntSmall,string OutdoorIntBig,string InternetBig,string InternetSmall,string PressBig,string PressSmall)
	    {
		    Template item = new Template();
		    
            item.UserID = UserID;
            
            item.Slide1 = Slide1;
            
            item.Slide2 = Slide2;
            
            item.Slide3 = Slide3;
            
            item.Slide4 = Slide4;
            
            item.Slide5 = Slide5;
            
            item.Slide6 = Slide6;
            
            item.Slide7 = Slide7;
            
            item.Slide8 = Slide8;
            
            item.TvSmall = TvSmall;
            
            item.TvBig = TvBig;
            
            item.CableSmall = CableSmall;
            
            item.CableBig = CableBig;
            
            item.RadioSmall = RadioSmall;
            
            item.RadioBig = RadioBig;
            
            item.RadioIntSmall = RadioIntSmall;
            
            item.RadioIntBig = RadioIntBig;
            
            item.OutdoorSmall = OutdoorSmall;
            
            item.OutdoorBig = OutdoorBig;
            
            item.OutdoorIntSmall = OutdoorIntSmall;
            
            item.OutdoorIntBig = OutdoorIntBig;
            
            item.InternetBig = InternetBig;
            
            item.InternetSmall = InternetSmall;
            
            item.PressBig = PressBig;
            
            item.PressSmall = PressSmall;
            
	    
		    item.Save(UserName);
	    }
    	
	    /// <summary>
	    /// Updates a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
	    public void Update(long Id,int UserID,string Slide1,string Slide2,string Slide3,string Slide4,string Slide5,string Slide6,string Slide7,string Slide8,string TvSmall,string TvBig,string CableSmall,string CableBig,string RadioSmall,string RadioBig,string RadioIntSmall,string RadioIntBig,string OutdoorSmall,string OutdoorBig,string OutdoorIntSmall,string OutdoorIntBig,string InternetBig,string InternetSmall,string PressBig,string PressSmall)
	    {
		    Template item = new Template();
	        item.MarkOld();
	        item.IsLoaded = true;
		    
			item.Id = Id;
				
			item.UserID = UserID;
				
			item.Slide1 = Slide1;
				
			item.Slide2 = Slide2;
				
			item.Slide3 = Slide3;
				
			item.Slide4 = Slide4;
				
			item.Slide5 = Slide5;
				
			item.Slide6 = Slide6;
				
			item.Slide7 = Slide7;
				
			item.Slide8 = Slide8;
				
			item.TvSmall = TvSmall;
				
			item.TvBig = TvBig;
				
			item.CableSmall = CableSmall;
				
			item.CableBig = CableBig;
				
			item.RadioSmall = RadioSmall;
				
			item.RadioBig = RadioBig;
				
			item.RadioIntSmall = RadioIntSmall;
				
			item.RadioIntBig = RadioIntBig;
				
			item.OutdoorSmall = OutdoorSmall;
				
			item.OutdoorBig = OutdoorBig;
				
			item.OutdoorIntSmall = OutdoorIntSmall;
				
			item.OutdoorIntBig = OutdoorIntBig;
				
			item.InternetBig = InternetBig;
				
			item.InternetSmall = InternetSmall;
				
			item.PressBig = PressBig;
				
			item.PressSmall = PressSmall;
				
	        item.Save(UserName);
	    }
    }
}
